DocTemplateList

Print
Visualforce Page Details
Name DocTemplateList
Label DocTemplateList
Namespace Prefix omnistudio
Api Version 56
Markup <apex:page controller="omnistudio.DocTemplateListController" showHeader="true" sidebar="false" standardStylesheets="false" extensions="omnistudio.DRDataPackRunnerController" docType="html-5.0" applyBodyTag="false" lightningStylesheets="true" > <head> <meta charset="utf-8"/> <apex:stylesheet value="{!IF(isLanguageRTL, URLFOR($Resource.omnistudio__slds, '/assets/styles/salesforce-lightning-design-system-vf.rtl.min.css'), URLFOR($Resource.omnistudio__slds, '/assets/styles/salesforce-lightning-design-system-vf.min.css'))}"/> <apex:stylesheet value="{!URLFOR($Resource.omnistudio__vlocity_assets, '/css/font-hack.css')}"/> <apex:includeScript value="/soap/ajax/56.0/connection.js"/> <apex:includeScript value="/xdomain/xdomain.js"/> <apex:includeScript value="{!URLFOR($Resource.omnistudio__vlocity_core_assets, '/latest/vlocity_core_assets.js')}"/> <apex:includeScript value="{!URLFOR($Resource.omnistudio__vlocity_assets, '/bower_components/ng-table/dist/ng-table.js')}"/> <apex:includeScript value="{!URLFOR($Resource.omnistudio__ngInfiniteScroll, '/build/ng-infinite-scroll.min.js')}"/> <apex:includeScript value="{!$Resource.omnistudio__SldsAngular}"/> <apex:includeScript value="{!$Resource.omnistudio__DRVComp}"/> <apex:includeScript value="/support/console/42.0/integration.js"/> <apex:includeScript value="{!$Resource.omnistudio__DocxGenerateSections}"/> <apex:includeScript value="{!URLFOR($Resource.omnistudio__docgenutil, 'docgenFieldMappingUtils.js')}"/> <apex:includeScript value="{!URLFOR($Resource.omnistudio__docxtemplater_bundle, '/jszip/jszip.min.js')}"/> <apex:includeScript value="{!URLFOR($Resource.omnistudio__docxtemplater_bundle, '/vendor/jszip-utils.js')}"/> <apex:includeScript value="{!URLFOR($Resource.omnistudio__docxtemplater_bundle, '/vendor/file-saver.min.js')}"/> <apex:includeScript value="{!URLFOR($Resource.omnistudio__docxtemplater_bundle, '/build/docxtemplater.v3.5.0.min.js')}"/> <apex:includeScript value="{!URLFOR($Resource.omnistudio__docxtemplater_bundle, '/modules/docxtemplater-link-module.v0.2.3.min.js')}"/> </head> <body> <div ng-app="docTemplateListApp" ng-controller="docTemplateListController" class="vlocity via-slds ng-cloak {!$User.UIThemeDisplayed}"> <div ng-if='showToastMessage()' class="demo-only " id='ToastMessage'> <div class="slds-notify_container slds-is-relative"> <div class="slds-notify slds-notify_toast slds-theme_success" role="alert" style="position: absolute;width: 500px;right: 0;left: 0;margin-left: auto;margin-right: auto;"> <span class="slds-assistive-text">success</span> <span class="slds-icon_container slds-icon-utility-success slds-m-right_small slds-no-flex slds-align-top" style="margin-left=2%;"> <svg class="slds-icon slds-icon_small" aria-hidden="true" style="margin-left:-5%;margin-right:5%;"> <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="{!URLFOR($Asset.SLDS, 'assets/icons/utility-sprite/svg/symbols.svg#success')}" /> </svg> {{labels.ToastMessageHeading}}<p style="margin-left:6%;font-size:smaller;min-width:27rem;">{{labels.ToastMessageDescription}}</p> </span> <button class="slds-button slds-button_icon slds-notify__close slds-button_icon-inverse" onclick="toastLaunch()"> <svg class="slds-button__icon slds-button__icon_small" aria-hidden="true"> <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="{!URLFOR($Asset.SLDS, 'assets/icons/utility-sprite/svg/symbols.svg#close')}" /> </svg> <span class="slds-assistive-text">{{labels.ToastMessageClose}}</span> </button> </div> </div> </div> <div class="slds-spinner_container" ng-show="vlcLoading"> <div class="slds-spinner slds-spinner_brand slds-spinner_large" aria-hidden="false" role="status"> <div class="slds-spinner__dot-a"></div> <div class="slds-spinner__dot-b"></div> </div> </div> <div ng-if="templateActionErrorMsg" class="slds-notify slds-notify_alert slds-theme_error slds-theme_alert-texture" role="alert"> <span class="slds-assistive-text">warning</span> <span class="slds-icon_container slds-icon-utility-warning slds-m-right_medium" title="warning"> <slds-svg-icon sprite="'utility'" icon="'warning'" size="'x-small'"></slds-svg-icon> </span> <h2 class="slds-m-right_small" ng-bind-html="templateActionErrorMsg"></h2> <button class="slds-button slds-button_icon slds-notify__close slds-button_icon-inverse" title="Close" ng-click="clearTemplateActionErrorMsg()"> <slds-svg-icon sprite="'utility'" icon="'close'" size="'x-small'"></slds-svg-icon> <span class="slds-assistive-text">Close</span> </button> </div> <slds-home page-label="'{!pageLabel}'" new-url="'{!newUrl}'" s-object-type="'{!documentTemplateObjType}'" row-actions="rowActions" id-prefix="document-home" default-columns="defaultColumns"></slds-home> <script type="text/ng-template" id="confirm-delete-template-modal.tpl.html"> <div class="slds-modal slds-fade-in-open" tabindex="-1" role="dialog"> <div class="slds-modal__container"> <div class="slds-modal__header"> <button class="slds-button slds-button_icon-inverse slds-modal__close" ng-click="$hide()"> <slds-svg-icon sprite="'action'" icon="'close'" size="'medium'"></slds-svg-icon> </button> <h4 class="slds-text-heading_medium">{{labels.CLMTemplateDeleteTemplate}}</h4> </div> <div class="slds-modal__content slds-p-around_medium"> <div> <p>{{labels.CLMClauseAreYouSureDeleteTemplate}} '{{currentTemplateName}}'?</p> </div> </div> <div class="slds-modal__footer"> <button type="button" class="slds-button slds-button_neutral" ng-click="$hide()">{{labels.CLMTemplateCancel}}</button> <button type="button" class="slds-button slds-button_destructive" ng-click="deleteDocumentTemplate(); $hide();">{{labels.CLMTemplateDeleteTemplate}}</button> </div> </div> </div> <div class="slds-backdrop slds-backdrop_open"></div> </script> </div> <c:VFActionFunction /> <script type="text/javascript"> window.docNewUrl = "{!newUrl}"; /** * Foundation package global variables **/ window.DocTemplateFieldMappings = JSON.parse('{!JSENCODE(docTemplateFieldMappings)}'); window.IsFoundation = {!isFoundationPkg}; window.nameSpacePrefix = '{!nameSpacePrefix}'; window.exportDrvType = '{!exportDrvType}'; if (typeof sforce !== 'undefined') { if (sforce.console && sforce.console.isInConsole()) { if(IsFoundation){ sforce.console.setTabTitle('Document Template Designer'); } else { sforce.console.setTabTitle('Vlocity Document Template'); } sforce.console.setTabIcon('standard:document'); } } window.sessionId = '{!vlocAccessToken}'; /* Labels */ window.i18n = { "SldsObjectHomeHeaderInfo": "{!JSENCODE($Label.omnistudio__SldsObjectHomeHeaderInfo)}", "RefreshData": "{!JSENCODE($Label.omnistudio__RefreshData)}", "Export": "{!JSENCODE($Label.omnistudio__Export)}", "New": "{!JSENCODE($Label.omnistudio__New)}", "FilterList": "{!JSENCODE($Label.omnistudio__FilterList)}", "Import": "{!JSENCODE($Label.omnistudio__Import)}", "AdditionalActions": "{!JSENCODE($Label.omnistudio__AdditionalActions)}", "Delete": "{!JSENCODE($Label.omnistudio__Delete)}", "Preview": "{!JSENCODE($Label.omnistudio__Preview)}", "LastModified": "{!JSENCODE($Label.omnistudio__LastModified)}", "Name": "{!JSENCODE($Label.omnistudio__Name)}", "ModifiedOnBy": "{!JSENCODE($Label.omnistudio__ModifiedOnBy)}", "DeleteLayout": "{!JSENCODE($Label.omnistudio__DeleteLayout)}", "InstallDataPack": "{!JSENCODE($Label.omnistudio__InstallDataPack)}", "DeleteLayoutConfirmation": "{!JSENCODE($Label.omnistudio__DeleteLayoutConfirmation)}", "Filters": "{!JSENCODE($Label.omnistudio__Filters)}", "HideFilter": "{!JSENCODE($Label.omnistudio__HideFilter)}", "Cancel": "{!JSENCODE($Label.omnistudio__Cancel)}", "Save": "{!JSENCODE($Label.omnistudio__Save)}", "ShowMe": "{!JSENCODE($Label.omnistudio__ShowMe)}", "MatchingAllOfTheseFilters": "{!JSENCODE($Label.omnistudio__MatchingAllOfTheseFilters)}", "Remove": "{!JSENCODE($Label.omnistudio__Remove)}", "NewFilter": "{!JSENCODE($Label.omnistudio__NewFilter)}", "AddFilter": "{!JSENCODE($Label.omnistudio__AddFilter)}", "RemoveAll": "{!JSENCODE($Label.omnistudio__RemoveAll)}", "Field": "{!JSENCODE($Label.omnistudio__Field)}", "Operator": "{!JSENCODE($Label.omnistudio__Operator)}", "Value": "{!JSENCODE($Label.omnistudio__Value)}", "Done": "{!JSENCODE($Label.omnistudio__Done)}", "AllType": "{!JSENCODE($Label.omnistudio__AllType)}", "MyType": "{!JSENCODE($Label.omnistudio__MyType)}" }; var labels = { 'CLMTemplateCloneTemplate': '{!JSENCODE($Label.omnistudio__CLMTemplateCloneTemplate)}', 'CLMTemplateActivate': '{!JSENCODE($Label.omnistudio__CLMTemplateActivate)}', 'CLMTemplateDeactivateTemplate': '{!JSENCODE($Label.omnistudio__CLMTemplateDeactivateTemplate)}', 'CLMTemplateCreateNewVersion': '{!JSENCODE($Label.omnistudio__CLMTemplateCreateNewVersion)}', 'CLMTemplateDeleteTemplate': '{!JSENCODE($Label.omnistudio__CLMTemplateDeleteTemplate)}', 'CLMTemplateSeeMoreContracts':'{!JSENCODE($Label.omnistudio__CLMTemplateSeeMoreContracts)}', 'CLMTemplateTheTemplate':'{!JSENCODE($Label.omnistudio__CLMTemplateTheTemplate)}', 'CLMTemplateCannotBeDeletedUsed':'{!JSENCODE($Label.omnistudio__CLMTemplateCannotBeDeletedUsed)}', 'CLMTemplateCannotBeDeactivatedUsed':'{!JSENCODE($Label.omnistudio__CLMTemplateCannotBeDeactivatedUsed)}', 'CLMClauseAreYouSureDeleteTemplate': '{!JSENCODE($Label.omnistudio__CLMClauseAreYouSureDeleteTemplate)}', 'ToastMessageHeading': '{!JSENCODE($Label.omnistudio__ToastMessageHeading)}', 'ToastMessageDescription': '{!JSENCODE($Label.omnistudio__ToastMessageDescription)}', 'CLMTemplateCancel': '{!JSENCODE($Label.omnistudio__CLMTemplateCancel)}', 'CLMCloneOnly': '{!JSENCODE($Label.omnistudio__CLMCloneOnly)}', 'CLMYes': '{!JSENCODE($Label.omnistudio__CLMYes)}' }; /* Remote Actions */ var remoteActions = { cloneDocumentTemplate: { action: '{!$RemoteAction.DocTemplateListController.cloneDocumentTemplate}', config: {escape: false} }, deactivateDocumentTemplate: { action: '{!$RemoteAction.DocTemplateListController.deactivateDocumentTemplate}', config: {escape: false} }, createNewVersion: { action: '{!$RemoteAction.DocTemplateListController.createNewVersionOfDocumentTemplate}', config: {escape: false} }, deleteDocumentTemplate: { action: '{!$RemoteAction.DocTemplateListController.deleteDocumentTemplate}', config: {escape: false} }, setTemplateContentVersionDocx: { action: '{!$RemoteAction.DocTemplateListController.setTemplateContentVersionDocx}', config: {escape: false} }, getTemplateLanguages: { action: '{!$RemoteAction.DocTemplateListController.getTemplateLanguages}', config: {escape: false} }, getTemplateContentVersion: { action: '{!$RemoteAction.DocTemplateListController.getTemplateContentVersion}', config: {escape: false} }, isVerticalFirstThenOs: { action: '{!$RemoteAction.DocTemplateListController.isVerticalFirstThenOs}', config: {escape: false} } }; function toastLaunch(){ var element = document.getElementById("ToastMessage"); element.classList.toggle("slds-hidden"); }; // Angular Module var docTemplateList = angular.module('docTemplateListApp', ['drvcomp', 'sldsangular', 'ngTable', 'vlocity', 'infinite-scroll']) .config(['$localizableProvider', function($localizableProvider) { 'use strict'; $localizableProvider.setLocalizedMap(window.i18n); $localizableProvider.setDebugMode(false); }]) .config(['remoteActionsProvider', function(remoteActionsProvider) { 'use strict'; remoteActionsProvider.setRemoteActions(window.remoteActions || {}); }]) .value('IsFoundation', window.IsFoundation) .value('nameSpacePrefix', window.nameSpacePrefix) .value('DocTemplateFieldMappings', window.DocTemplateFieldMappings); // Angular Controller docTemplateList.controller('docTemplateListController', ['$scope', '$filter', '$localizable', 'remoteActions', '$sldsModal', 'IsFoundation','nameSpacePrefix', function($scope, $filter, $localizable, remoteActions, $sldsModal, IsFoundation, nameSpacePrefix) { 'use strict'; var templateTypeCodeMap = { 'Vlocity Web Template': 'web', 'Microsoft Word .DOCX Template': 'docx', 'Microsoft Powerpoint .PPTX Template': 'pptx', // Foundation package 'MicrosoftWord': 'docx', 'MicrosoftPowerpoint': 'pptx', 'Microsoft365Word':'word365' }; var templateLanguageOptions = []; $scope.vlcLoading = false; $scope.templateActionErrorMsg = ''; $scope.labels = labels; // onInit Method for Toast Message this.$onInit = function() { $scope.isVerticalFirstThenOs(); }; $scope.isVerticalFirstThenOsBooleanValue=null; // Method to retrieve the value of isVerticalFirstThenOs boolean from DocTemplateListController.cls $scope.isVerticalFirstThenOs=function() { remoteActions.isVerticalFirstThenOs().then(function(result) { if (result === true){ $scope.isVerticalFirstThenOsBooleanValue = true; }else { $scope.isVerticalFirstThenOsBooleanValue = false; } }, function(error) { console.log('Error in DocTemplateListPage.controller method '+error); }); }; // Method which returns true if the toast message needs to be displayed on the Document Template List Page and false for otherwise based on the boolean isVerticalFirstThenOsBooleanValue . $scope.showToastMessage = function() { if ( $scope.isVerticalFirstThenOsBooleanValue === true ){ return true; }else { return false; } }; /** * Returns displayValue for language column. ex: if langValue = "en_US", returns "English" as displayValue. */ function getLanguageDisplayValue(langValue) { for(var i=0; i<templateLanguageOptions.length; i++) { if(langValue === templateLanguageOptions[i].Value) { return templateLanguageOptions[i].Label; } } } // Language list. $scope.getTemplateLanguages =function() { remoteActions.getTemplateLanguages().then(function(result) { templateLanguageOptions = result; //Adding 'None' option to the Language dropdown list. templateLanguageOptions.push({Label: "--None--",Value:"", isActive: true}); }); }; $scope.getTemplateLanguages(); $scope.cloneDocumentTemplateFoundation = function(documentTemplateId) { $scope.vlcLoading = true; remoteActions.getTemplateContentVersion(documentTemplateId).then(function(result){ $scope.cloneDocumentTemplate(documentTemplateId, result.templateFile.Id); }); } $scope.cloneDocumentTemplate = function(documentTemplateId, contentVersionId) { $scope.vlcLoading = true; $scope.sourceTemplateId = documentTemplateId; remoteActions.cloneDocumentTemplate(documentTemplateId).then(function(result) { $scope.templateId = result.templateData.Id; $scope.clonedTemplateDetails = result.templateSections; var templateType = result.templateData[getTemplateField('TemplateContentFormat__c')]; $scope.templateTypeParam = (templateType ? '&templateType=' + templateTypeCodeMap[templateType] : ''); if (templateType === 'Microsoft Word .DOCX Template' || templateType === 'Microsoft Powerpoint .PPTX Template') { $scope.globalKey = result.cvGlobalKey; $scope.sourceTemplateSections = result.srcTemplateSections; $scope.getContentVersionData(contentVersionId); } else { location.href = '/apex/' + nameSpacePrefix + 'DocumentTemplate?templateId=' + $scope.templateId + $scope.templateTypeParam; } }, function(error) { $scope.templateActionErrorMsg = '<div><p>Visualforce Remoting Exception: ' + error.message + '</p></div>'; $scope.vlcLoading = false; }); }; $scope.deactivateDocumentTemplate = function(documentTemplateId, documentTemplateName) { $scope.vlcLoading = true; remoteActions.deactivateDocumentTemplate(documentTemplateId).then(function(result) { if (result.length === 0) { location.href = '/apex/DocTemplateList'; } else { $scope.showTemplateActionErrorMsg(result, documentTemplateName, 'DEACTIVATE'); $scope.vlcLoading = false; } }, function(error) { $scope.templateActionErrorMsg = '<div><p>Visualforce Remoting Exception: ' + error.message + '</p></div>'; $scope.vlcLoading = false; }); }; $scope.createNewVersionFoundation = function(documentTemplateId) { $scope.vlcLoading = true; remoteActions.getTemplateContentVersion(documentTemplateId).then(function(result){ $scope.createNewVersion(documentTemplateId, result.templateFile.Id); }); } $scope.createNewVersion = function(documentTemplateId, contentVersionId) { $scope.vlcLoading = true; $scope.sourceTemplateId = documentTemplateId; remoteActions.createNewVersion(documentTemplateId).then(function(result) { $scope.templateId = result.templateData.Id; $scope.clonedTemplateDetails = result.templateSections; var templateType = result.templateData[ getTemplateField('TemplateContentFormat__c')]; $scope.templateTypeParam = (templateType ? '&templateType=' + templateTypeCodeMap[templateType] : ''); if (templateType === 'Microsoft Word .DOCX Template' || templateType === 'Microsoft Powerpoint .PPTX Template') { $scope.globalKey = result.cvGlobalKey; $scope.sourceTemplateSections = result.srcTemplateSections; $scope.getContentVersionData(contentVersionId); } else { location.href = '/apex/' + nameSpacePrefix + 'DocumentTemplate?templateId=' + $scope.templateId + $scope.templateTypeParam; } }, function(error) { $scope.templateActionErrorMsg = '<div><p>Visualforce Remoting Exception: ' + error.message + '</p></div>'; $scope.vlcLoading = false; }); }; $scope.confirmDeleteTemplate = function(templateId, templateName) { $scope.currentTemplateId = templateId; $scope.currentTemplateName = templateName; $sldsModal({ templateUrl: 'confirm-delete-template-modal.tpl.html', container: 'div.vlocity', placement: 'center', html: true, scope: $scope }); }; $scope.deleteDocumentTemplate = function() { $scope.vlcLoading = true; remoteActions.deleteDocumentTemplate($scope.currentTemplateId).then(function(result) { if (result.length === 0) { location.href = '/apex/DocTemplateList'; } else { $scope.showTemplateActionErrorMsg(result, $scope.currentTemplateName, 'DELETE'); $scope.vlcLoading = false; } }, function(error) { $scope.templateActionErrorMsg = '<div><p>Visualforce Remoting Exception: ' + error.message + '</p></div>'; $scope.vlcLoading = false; }); }; $scope.getContentVersionData = function(contentVersionId) { sforce.connection.sessionId = window.sessionId; var queryString = 'Select Id, Title, VersionData FROM ContentVersion where Id = \'' + contentVersionId + '\''; sforce.connection.query(queryString, { onSuccess: function(result) { var contentVersion = { 'Id': result.records.Id, 'Title': result.records.Title, 'VersionData': result.records.VersionData } if ($scope.sourceTemplateSections && $scope.sourceTemplateSections.length > 0) { var docSectionData = []; for(var i=0; i<$scope.sourceTemplateSections.length; i++) { var tempSectionObj = {}; tempSectionObj['sectionId']= $scope.sourceTemplateSections[i].Id; docSectionData.push(tempSectionObj) } var inputMap = { 'docName' : contentVersion.Title, 'docSectionData': docSectionData, 'newTempSectionData': $scope.clonedTemplateDetails } replaceOldSectionIdWithNewId(contentVersion.VersionData, inputMap).then(function (result) { contentVersion.VersionData = result.fileContent $scope.createContentVersion(contentVersion); }); } else { $scope.createContentVersion(contentVersion); } }, onFailure: function(result) { var errorMsg = result.faultstring; console.error('errorMsg: ', errorMsg); $scope.templateActionErrorMsg = '<div><p>SOAP API Exception: ' + errorMsg + '</p></div>'; $scope.vlcLoading = false; } }); }; $scope.createContentVersion = function(contentVersion) { var contentVersionSObj = new sforce.SObject('ContentVersion'); contentVersionSObj.Title = contentVersion.Title; contentVersionSObj.PathOnClient = contentVersion.Title; contentVersionSObj.VersionData = contentVersion.VersionData; contentVersionSObj[IsFoundation?'ExternalDocumentInfo2':nameSpacePrefix + 'GlobalKey__c'] = $scope.globalKey; sforce.connection.create([contentVersionSObj], { onSuccess: function(result) { var status = result[0].getBoolean('success'); var generatedContentVersionId = result[0].id; console.log('generatedContentVersionId: ', generatedContentVersionId); $scope.setTemplateContentVersionDocx($scope.templateId, generatedContentVersionId, true); }, onFailure: function(result) { var errorMsg = result.faultstring; console.error('errorMsg: ', errorMsg); $scope.templateActionErrorMsg = '<div><p>SOAP API Exception: ' + errorMsg + '</p></div>'; $scope.vlcLoading = false; } }); }; $scope.setTemplateContentVersionDocx = function(templateId, contentVersionId, isSectionIdsReplaced) { remoteActions.setTemplateContentVersionDocx(templateId, contentVersionId, isSectionIdsReplaced).then(function(result) { location.href = '/apex/' + nameSpacePrefix + 'DocumentTemplate?templateId=' + templateId + $scope.templateTypeParam; }, function(error) { $scope.templateActionErrorMsg = '<div><p>Visualforce Remoting Exception: ' + error.message + '</p></div>'; $scope.vlcLoading = false; }); }; $scope.showTemplateActionErrorMsg = function(contractList, documentTemplateName, action) { var i, j, contracts, versions, versionNumbers; function sortNumber(a, b) { return a - b; } contracts = ''; for (i = 0; i < contractList.length; i++) { versions = ''; versionNumbers = contractList[i].contractversion.sort(sortNumber); for (j = 0; j < versionNumbers.length; j++) { if (j === contractList[i].contractversion.length - 1) { versions += versionNumbers[j] + '.'; } else { versions += versionNumbers[j] + ', '; } } if (!contractList[i].contractname) { contractList[i].contractname = ''; } contracts += '<li class="slds-text-align_left">' + contractList[i].contractname + ' (<a href="/' + contractList[i].contractid + '" target="_blank">' + contractList[i].contractnumber + '</a>) - Versions: ' + versions; } if (action === 'DELETE') { $scope.templateActionErrorMsg = '<div><p class="slds-m-bottom_small">' + labels.CLMTemplateTheTemplate + ' ' + documentTemplateName + ' ' + labels.CLMTemplateCannotBeDeletedUsed + '</p><ul class="slds-list_dotted slds-p-left_small">' + contracts + '</ul></div>'; } else if (action === 'DEACTIVATE') { $scope.templateActionErrorMsg = '<div><p class="slds-m-bottom_small">' + labels.CLMTemplateTheTemplate + ' ' + documentTemplateName + ' ' + labels.CLMTemplateCannotBeDeactivatedUsed + '</p><ul class="slds-list_dotted slds-p-left_small">' + contracts + '</ul></div>'; } }; $scope.clearTemplateActionErrorMsg = function() { $scope.templateActionErrorMsg = ''; }; /* sldsHome directive data */ // row action config $scope.rowActions = [ { text: labels.CLMTemplateCloneTemplate, icon: { sprite: 'action', icon: 'clone' }, click: function(row, group) { if(IsFoundation){ $scope.cloneDocumentTemplateFoundation(row.Id); } else { $scope.cloneDocumentTemplate(row.Id, row[getTemplateField('TemplateContentVersionId__c')]); } }, hide: function(row, group) { if (IsFoundation) { return !(row.Namespace || row[getTemplateField('Status__c')] == 'Active'); } return (row[getTemplateField('Status__c')] !== 'Active'); } }, { text: labels.CLMTemplateDeactivateTemplate, icon: { sprite: 'action', icon: 'remove' }, click: function(row, group) { $scope.deactivateDocumentTemplate(row.Id, row.Name); }, hide: function(row, group) { return (row[getTemplateField('Status__c')] !== 'Active'); } }, /*{ text: labels.CLMTemplateActivate, icon: { sprite: 'action', icon: 'check' }, click: function(row, group) { $scope.activateDocumentTemplate(row.Id); }, hide: function(row, group) { return (row[namespacePrefix + 'Status__c'] !== 'Draft'); } },*/ { text: labels.CLMTemplateCreateNewVersion, icon: { sprite: 'utility', icon: 'new' }, click: function(row, group) { if(IsFoundation) { $scope.createNewVersionFoundation(row.Id); } else { $scope.createNewVersion(row.Id, row[getTemplateField('TemplateContentVersionId__c')]); } }, hide: function(row, group) { return (row[getTemplateField('Status__c')] === 'Draft'); } }, { text: labels.CLMTemplateDeleteTemplate, icon: { sprite: 'action', icon: 'delete' }, click: function(row, group) { $scope.confirmDeleteTemplate(row.Id, row.Name); }, hide: function(row, group) { if (IsFoundation) { return row.Namespace; } } }, { type: 'export', drvType: window.exportDrvType, hide: function(row, group) { if (IsFoundation) { return row.Namespace; } } } ]; // column config $scope.defaultColumns = [ { //field: $localizable('Name', 'Name'), field: 'Name', additionalFields: [ getTemplateField('VersionNumber__c')], dynamic: true, getValue: function($scope, row) { var templateTypeParam = row[getTemplateField('TemplateContentFormat__c')] ? '&templateType=' + templateTypeCodeMap[row[getTemplateField('TemplateContentFormat__c')]] : ''; var url = window.docNewUrl + '?templateId=' + row.Id + templateTypeParam; return '<a href="' +url+ '" ng-mousedown="$root.vlocityOpenUrl(\'' + url + '\', $event)">' + _.escape(row.Name) + ' (Version ' + row[getTemplateField('VersionNumber__c')] + ')</a>'; }, getGroupValue: function($scope, $group) { return '<span>' + _.escape($group.data[0].Name) + '</span>'; } }, { field: getTemplateField('TemplateContentFormat__c'), getValue: function() { return ''; } }, { field: getTemplateField('LocaleCode__c'), getValue: function($scope, row) { return getLanguageDisplayValue(row[getTemplateField('LocaleCode__c')]); }, getGroupValue: function($scope, $group) { return getLanguageDisplayValue($group.data[0][getTemplateField('LocaleCode__c')]); } }, { field: getTemplateField('ApplicableTypes__c'), getValue: function() { return ''; } }, { field: getTemplateField('MappingType__c'), getValue: function() { return ''; } }, /*{ field: namespacePrefix + 'UsageType__c', getValue: function() { return ''; } },*/ { field: getTemplateField('Status__c'), getValue: function($scope, row) { return row[getTemplateField('Status__c')]; } }, { //title: $localizable('LastModified', 'Last Modified'), field: 'LastModifiedDate', getValue: function($scope, row) { return 'Modified on ' + $filter('date')(row.LastModifiedDate) + ' by ' + _.escape(row.LastModifiedBy.Name); }, getGroupValue: function($scope, $group) { var mostRecent = $group.data[0].LastModifiedDate; $group.data.forEach(function(data) { if (data.LastModifiedDate > mostRecent) { mostRecent = data.LastModifiedDate; } }); return $filter('date')(mostRecent); } }, { field: getTemplateField('IsActive__c'), additionalFields: [getTemplateField('Status__c'), getTemplateField('TemplateContentVersionId__c')], shrink: true, dynamic: true, getValue: function($scope, row) { if (row[getTemplateField('IsActive__c')]) { return '<span class="slds-icon_container" title="Is Active"><slds-svg-icon sprite="\'utility\'"' + ' icon="\'success\'" size="\'x-small\'" extra-classes="\'slds-icon-text-default\'"></slds-svg-icon></span>'; } }, getGroupValue: function($scope, $group) { var hasAnActiveEntry = false; $group.data.forEach(function(row) { if (row[getTemplateField('IsActive__c')]) { hasAnActiveEntry = true; return false; } }); if (hasAnActiveEntry) { return '<span class="slds-icon_container" title="Is Active"><slds-svg-icon sprite="\'utility\'"' + ' icon="\'success\'" size="\'x-small\'" extra-classes="\'slds-icon-text-default\'"></slds-svg-icon></span>'; } } } ]; if(IsFoundation){ $scope.defaultColumns.push( { title: labels.CLMCloneOnly, field: 'Namespace', getValue: function() { return ''; }, getGroupValue: function($scope, $group) { if ($group.data[0].Namespace) { return '<span>' + labels.CLMYes + '</span>'; } } } ); console.log('foundation package... trimming columns'); $scope.defaultColumns = $scope.defaultColumns .map((column) => { //clean up additional fields if(column.additionalFields !== undefined) { column.additionalFields = column.additionalFields.filter((additionalField)=> additionalField !== undefined); } return column; }) .filter((column) => { // clean up fields not related to foundation package return column.field !== undefined; }); } }]); </script> </body> </apex:page>